#include "Blocks/ArrowBlock.h"
#include "Components/ComponentMiner.h"
#include "Components/ComponentCreature.h"
#include "Components/ComponentCreatureModel.h"
#include "Managers/BlocksManager.h"

namespace PocketSurvival
{
    static uint8_t order[9] = {
        0,
        1,
        8,
        2,
        3,
        4,
        5,
        6,
        7};

    static float weaponPowers[9] = {
        5.0f,
        7.0f,
        14.0f,
        18.0f,
        4.0f,
        28.0f,
        36.0f,
        8.0f,
        10.0f};

    static float explosionPressures[9] = {
        0.0f,
        0.0f,
        0.0f,
        0.0f,
        0.0f,
        0.0f,
        0.0f,
        40.0f,
        0.0f};

    void ArrowBlock::getCreativeValues(std::vector<int32_t> &blockVec)
    {
        for (int32_t index = 0; index < sizeof(order); ++index)
        {
            int32_t data = SetArrowType(0, (ArrowType)(order[index] + 1));
            blockVec.push_back(Terrain::MakeBlockValue(Index(), 0, data));
        }
    }

    float ArrowBlock::getExplosionPressure(int32_t value)
    {
        int32_t arrowType = Terrain::ExtractData(value);
        if (arrowType < 0 || arrowType >= (sizeof(explosionPressures) / sizeof(explosionPressures[0])))
        {
            return 0.0f;
        }
        return explosionPressures[arrowType];
    }
    float ArrowBlock::getProjectilePower(int32_t value)
    {
        int32_t arrowType = Terrain::ExtractData(value);
        if (arrowType < 0 || arrowType >= (sizeof(weaponPowers) / sizeof(weaponPowers[0])))
        {
            return 0.0f;
        }
        return weaponPowers[arrowType];
    }

    int32_t ArrowBlock::getIndex()
    {
        return Index();
    }
    const std::string &ArrowBlock::getBlockName()
    {
        static std::string blockName = "ArrowBlock";
        return blockName;
    }

} // namespace PocketSurvival
